package com.car.rental.vehicle.controller;

import com.car.rental.common.core.result.ResponseResult;
import com.car.rental.vehicle.entity.VehicleImage;
import com.car.rental.vehicle.service.VehicleImageService;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vehicle/image")
@RequiredArgsConstructor
public class VehicleImageController {
    
    private final VehicleImageService vehicleImageService;
    private static final Logger log = LoggerFactory.getLogger(VehicleImageController.class);
    
    @GetMapping("/list/{vehicleId}")
    public ResponseResult<List<VehicleImage>> list(@PathVariable Long vehicleId) {
        return ResponseResult.success(vehicleImageService.getByVehicleId(vehicleId));
    }
    
    @PostMapping
    public ResponseResult<Boolean> add(@RequestBody VehicleImage vehicleImage) {
        return ResponseResult.success(vehicleImageService.save(vehicleImage));
    }
    
    /**
     * 获取所有车辆图片（公开接口）
     */
    @GetMapping("/public")
    public ResponseResult<List<VehicleImage>> getAllImages() {
        log.info("获取所有车辆图片");
        return ResponseResult.success(vehicleImageService.list());
    }
} 